#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;

int H, W;
char s[40][40];

ll solve(int x, int l, int r) {
	//cerr << x << " " << l << " " << r << endl;
	assert(l <= r);
	if(l == r) return s[x][r] - '0';
	int pos = l;
	rep(i, l, r) if(s[x][i] == '+' || s[x][i] == '-' || s[x][i] == '*') pos = i;
	ll xl = solve(x + 1, l, pos - 1), xr = solve(x + 1, pos + 1, r);
	if(s[x][pos] == '+') return xl + xr;
	if(s[x][pos] == '-') return xl - xr;
	if(s[x][pos] == '*') return xl * xr;
	return assert(0), 0;
}

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	H = in, W = in;
	rep(i, 1, H) scanf("%s", s[i] + 1);
	cout << solve(1, 1, W) << endl;
	
	return 0;
}
